Skip to content

gh-148252: Fix stack depth calculation in binary reader on 32-bit platforms#148253

Merged
pablogsal merged 1 commit intopython:mainfrom
pablogsal:gh-148178-pyb-32bit-fix
Apr 13, 2026
Merged

gh-148252: Fix stack depth calculation in binary reader on 32-bit platforms#148253
pablogsal merged 1 commit intopython:mainfrom
pablogsal:gh-148178-pyb-32bit-fix

Conversation

@pablogsal
Copy link
Copy Markdown
Member

@pablogsal pablogsal commented Apr 8, 2026

…it platforms

Compute ``final_depth`` in ``decode_stack_pop_push()`` and
``decode_stack_suffix()`` using ``uint64_t`` before validating it.

On 32-bit builds, using ``size_t`` arithmetic for ``keep + push`` can wrap
for large input values, causing the later bounds check to validate the wrong
final depth. Using a widened type keeps the validation aligned with the
actual result.
@pablogsal pablogsal force-pushed the gh-148178-pyb-32bit-fix branch from 8d1359f to cc18e91 Compare April 8, 2026 22:53
@pablogsal pablogsal marked this pull request as ready for review April 8, 2026 23:03
@pablogsal pablogsal merged commit eb4c78d into python:main Apr 13, 2026
56 checks passed
@pablogsal pablogsal deleted the gh-148178-pyb-32bit-fix branch April 13, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant